home *** CD-ROM | disk | FTP | other *** search
/ Amiga Magazin: Amiga-CD 1996 March / Amiga-CD 1996 #3.iso / pd-software / mui_3.1 / developer / c / examples / balancing.c < prev    next >
C/C++ Source or Header  |  1996-01-19  |  4KB  |  126 lines

  1. #include "demo.h"
  2.  
  3. int main(int argc,char *argv[])
  4. {
  5.     APTR app,window;
  6.  
  7.     init();
  8.  
  9.     app = ApplicationObject,
  10.         MUIA_Application_Title      , "BalanceDemo",
  11.         MUIA_Application_Version    , "$VER: BalanceDemo 12.10 (21.11.95)",
  12.         MUIA_Application_Copyright  , "©1995, Stefan Stuntz",
  13.         MUIA_Application_Author     , "Stefan Stuntz",
  14.         MUIA_Application_Description, "Show balancing groups",
  15.         MUIA_Application_Base       , "BALANCEDEMO",
  16.  
  17.         SubWindow, window = WindowObject,
  18.             MUIA_Window_Title, "Balancing Groups",
  19.             MUIA_Window_ID   , MAKE_ID('B','A','L','A'),
  20.             MUIA_Window_Width , MUIV_Window_Width_Screen(50),
  21.             MUIA_Window_Height, MUIV_Window_Height_Screen(50),
  22.  
  23.             WindowContents, HGroup,
  24.  
  25.                 Child, VGroup, GroupFrame, MUIA_Weight, 15,
  26.                     Child, RectangleObject, TextFrame, MUIA_Weight,  50, End,
  27.                     Child, RectangleObject, TextFrame, MUIA_Weight, 100, End,
  28.                     Child, BalanceObject, End,
  29.                     Child, RectangleObject, TextFrame, MUIA_Weight, 200, End,
  30.                     End,
  31.  
  32.                 Child, BalanceObject, End,
  33.  
  34.                 Child, VGroup,
  35.                     Child, HGroup, GroupFrame,
  36.                         Child, RectangleObject, TextFrame, MUIA_ObjectID, 123, End,
  37.                         Child, BalanceObject, End,
  38.                         Child, RectangleObject, TextFrame, MUIA_ObjectID, 456, End,
  39.                         End,
  40.                     Child, HGroup, GroupFrame,
  41.                         Child, RectangleObject, TextFrame, End,
  42.                         Child, BalanceObject, End,
  43.                         Child, RectangleObject, TextFrame, End,
  44.                         Child, BalanceObject, End,
  45.                         Child, RectangleObject, TextFrame, End,
  46.                         Child, BalanceObject, End,
  47.                         Child, RectangleObject, TextFrame, End,
  48.                         Child, BalanceObject, End,
  49.                         Child, RectangleObject, TextFrame, End,
  50.                         End,
  51.                     Child, HGroup, GroupFrame,
  52.                         Child, HGroup,
  53.                             Child, RectangleObject, TextFrame, End,
  54.                             Child, BalanceObject, End,
  55.                             Child, RectangleObject, TextFrame, End,
  56.                             End,
  57.                         Child, BalanceObject, End,
  58.                         Child, HGroup,
  59.                             Child, RectangleObject, TextFrame, End,
  60.                             Child, BalanceObject, End,
  61.                             Child, RectangleObject, TextFrame, End,
  62.                             End,
  63.                         End,
  64.                     Child, HGroup, GroupFrame,
  65.                         Child, RectangleObject, TextFrame, MUIA_Weight,  50, End,
  66.                         Child, RectangleObject, TextFrame, MUIA_Weight, 100, End,
  67.                         Child, BalanceObject, End,
  68.                         Child, RectangleObject, TextFrame, MUIA_Weight, 200, End,
  69.                         End,
  70.                     Child, HGroup, GroupFrame,
  71.                         Child, SimpleButton("Also"),
  72.                         Child, BalanceObject, End,
  73.                         Child, SimpleButton("Try"),
  74.                         Child, BalanceObject, End,
  75.                         Child, SimpleButton("Sizing"),
  76.                         Child, BalanceObject, End,
  77.                         Child, SimpleButton("With"),
  78.                         Child, BalanceObject, End,
  79.                         Child, SimpleButton("Shift"),
  80.                         End,
  81.                     End,
  82.                 End,
  83.             End,
  84.  
  85.         End;
  86.  
  87.     if (!app)
  88.         fail(app,"Failed to create Application.");
  89.  
  90.     DoMethod(window,MUIM_Notify,MUIA_Window_CloseRequest,TRUE,
  91.         app,2,MUIM_Application_ReturnID,MUIV_Application_ReturnID_Quit);
  92.  
  93.  
  94. /*
  95. ** This is the ideal input loop for an object oriented MUI application.
  96. ** Everything is encapsulated in classes, no return ids need to be used,
  97. ** we just check if the program shall terminate.
  98. ** Note that MUIM_Application_NewInput expects sigs to contain the result
  99. ** from Wait() (or 0). This makes the input loop significantly faster.
  100. */
  101.  
  102.     set(window,MUIA_Window_Open,TRUE);
  103.  
  104.     {
  105.         ULONG sigs = 0;
  106.  
  107.         while (DoMethod(app,MUIM_Application_NewInput,&sigs) != MUIV_Application_ReturnID_Quit)
  108.         {
  109.             if (sigs)
  110.             {
  111.                 sigs = Wait(sigs | SIGBREAKF_CTRL_C);
  112.                 if (sigs & SIGBREAKF_CTRL_C) break;
  113.             }
  114.         }
  115.     }
  116.  
  117.     set(window,MUIA_Window_Open,FALSE);
  118.  
  119.  
  120. /*
  121. ** Shut down...
  122. */
  123.  
  124.     fail(app,NULL);
  125. }
  126.